Free ActionScript
Home
AS3 Scripts
AS2 Scripts
Resources
About
Contact
A newer, better version of my scrollbar class. This one does not have any classes attached to movieclips. Instead you pass it a content clip, mask clip, track clip and slider clip like so:
_scrollbar = new Scrollbar(); _scrollbar.init(content, contentMask, track, slider);
This version also supports mouse wheel scrolling.
Download Fla Sample
Simple AS3 function to get the number of days in a month/year.
function getNumberOfDays ( $year: int , $month: int ) : int { var month: Date = new Date ( $year, $month + 1 , 0 ) ; return month. date ; } //jan trace ( getNumberOfDays ( 2010 , 0 ) ) ; // traces 31 //feb trace ( getNumberOfDays ( 2010 , 1 ) ) ; // traces 28 //dec trace ( getNumberOfDays ( 2010 , 11 ) ) ; // traces 31
By request, here is a simple box drawing class. Click and drag to draw box based on mouse position.
This can be used as an object selecting mechanism in games to select multiple objects at the same time.
Click and drag to draw box
/** * Draw Box class * --------------------- * VERSION: 1.0 * DATE: 11/14/2010 * AS3 * UPDATES AND DOCUMENTATION AT: http://www.FreeActionScript.com **/ package com. freeactionscript { import flash. display . DisplayObjectContainer ; import flash. events . MouseEvent ; import flash. display . Sprite ; import flash. events . Event ; public class Box extends Sprite { private var _canvas:DisplayObjectContainer; private var _startX: Number ; private var _startY: Number ; private var _endX: Number ; private var _endY: Number ; public function Box ( $canvas:DisplayObjectContainer, $startX: Number , $startY: Number ) { _canvas = $canvas; _startX = $startX; _startY = $startY; _endX = _canvas. mouseX ; _endY = _canvas. mouseY ; _canvas. addEventListener ( MouseEvent. MOUSE_MOVE , onMouseMoveHandler ) ; _canvas. addEventListener ( MouseEvent. MOUSE_UP , onMouseUpHandler ) ; _canvas. addEventListener ( Event. ENTER_FRAME , onEnterFrameHandler ) ; } private function onMouseMoveHandler ( event:MouseEvent ) : void { _endX = _canvas. mouseX ; _endY = _canvas. mouseY ; } private function onMouseUpHandler ( event:MouseEvent ) : void { _canvas. removeEventListener ( MouseEvent. MOUSE_MOVE , onMouseMoveHandler ) ; _canvas. removeEventListener ( MouseEvent. MOUSE_UP , onMouseUpHandler ) ; _canvas. removeEventListener ( Event. ENTER_FRAME , onEnterFrameHandler ) ; } private function onEnterFrameHandler ( event:Event ) : void { graphics. clear ( ) ; graphics. lineStyle ( 2 , 0x88B1CC ) ; graphics. moveTo ( _startX, _startY ) ; graphics. beginFill ( 0x88B1CC, .25 ) ; graphics. lineTo ( _endX, _startY ) ; graphics. lineTo ( _endX, _endY ) ; graphics. lineTo ( _startX, _endY ) ; graphics. lineTo ( _startX, _startY ) ; graphics. endFill ( ) ; } } }
Here is a scroller widget. Sized dynamically based on content movieclip size.
Page 1 of 2
AS3 Effects
AS3 Gadgets
Game Examples AS2 Effects Animated Effects Dynamic Enemy AI Game Engine Game Weapons Images Interface Math Security
Effects Animated
Effects Dynamic
Enemy AI
Game Engine
Game Weapons
Images
Interface
Math
Security
Game Examples AS3 Basics Bitmap Blitting Collision Detection Enemy AI Movement Physics Space Shooter User Interface Weapon System
Basics
Bitmap Blitting
Collision Detection
Movement
Physics
Space Shooter
User Interface
Weapon System
Site Updates
718Hosting.com
Actionscript.org Forums
Flash Game Blogs
Flash Game License
Flashkit Forums
gotoAndLearn
IndieGames.com
Kirupa’s Tutorials
Kongregate Forums
MochiAds Resources
Philip Radvan
Photon Storm
Polygonal
Radvan Media
Tonypa’s Tutorials
Register
Log in
Entries RSS
Comments RSS
WordPress.org